package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.PtfInterfaceService;
import com.ruoyi.system.service.IPtfInterfaceServiceService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 接口服务Controller
 * 
 * @author ruoyi
 * @date 2022-11-20
 */
@RestController
@RequestMapping("/interfaceService")
public class PtfInterfaceServiceController extends BaseController
{
    @Autowired
    private IPtfInterfaceServiceService ptfInterfaceServiceService;

    /**
     * 查询接口服务列表
     */
    @RequiresPermissions("system:interfaceService:list")
    @GetMapping("/list")
    public TableDataInfo list(PtfInterfaceService ptfInterfaceService)
    {
        startPage();
        List<PtfInterfaceService> list = ptfInterfaceServiceService.selectPtfInterfaceServiceList(ptfInterfaceService);
        return getDataTable(list);
    }

    /**
     * 导出接口服务列表
     */
    @RequiresPermissions("system:interfaceService:export")
    @Log(title = "接口服务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PtfInterfaceService ptfInterfaceService)
    {
        List<PtfInterfaceService> list = ptfInterfaceServiceService.selectPtfInterfaceServiceList(ptfInterfaceService);
        ExcelUtil<PtfInterfaceService> util = new ExcelUtil<PtfInterfaceService>(PtfInterfaceService.class);
        util.exportExcel(response, list, "接口服务数据");
    }

    /**
     * 获取接口服务详细信息
     */
    @RequiresPermissions("system:interfaceService:query")
    @GetMapping(value = "/{serviceId}")
    public AjaxResult getInfo(@PathVariable("serviceId") Long serviceId)
    {
        return AjaxResult.success(ptfInterfaceServiceService.selectPtfInterfaceServiceByServiceId(serviceId));
    }

    /**
     * 新增接口服务
     */
    @RequiresPermissions("system:interfaceService:add")
    @Log(title = "接口服务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PtfInterfaceService ptfInterfaceService)
    {
        return toAjax(ptfInterfaceServiceService.insertPtfInterfaceService(ptfInterfaceService));
    }

    /**
     * 修改接口服务
     */
    @RequiresPermissions("system:interfaceService:edit")
    @Log(title = "接口服务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PtfInterfaceService ptfInterfaceService)
    {
        return toAjax(ptfInterfaceServiceService.updatePtfInterfaceService(ptfInterfaceService));
    }

    /**
     * 删除接口服务
     */
    @RequiresPermissions("system:interfaceService:remove")
    @Log(title = "接口服务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{serviceIds}")
    public AjaxResult remove(@PathVariable Long[] serviceIds)
    {
        return toAjax(ptfInterfaceServiceService.deletePtfInterfaceServiceByServiceIds(serviceIds));
    }
}
